import sys
import threading
import asyncio
import webview

from database import DatabaseManager
from opcua_client import OpcUaMonitor
from api import ApiInterface

def main():
    # 初始化组件
    db_manager = DatabaseManager()
    opcua_monitor = OpcUaMonitor(db_manager)
    api_interface = ApiInterface(db_manager, opcua_monitor)
    
    # 创建Webview窗口
    window = webview.create_window(
        "OPC UA 点位监控",
        "ui/index.html",
        width=1400,
        height=800,
        resizable=True,
        js_api=api_interface
    )
    
    # 启动GUI
    webview.start(debug=True, http_server=True, gui='edge')

if __name__ == '__main__':
    main()